import request from '../utils/request.axios';
import { API } from '../config/API';

// 新增商品类型
export async function addCommodity(params) {
  return request(`${API}/api/commodity`, {
    method: 'POST',
    body: params,
  });
}

// 修改商品
export async function updateCommodity(params) {
  return request(`${API}/api/commodity`, {
    method: 'PUT',
    body: params,
  });
}

// 删除商品
export async function deleteCommodity(params) {
  return request(`${API}/api/commodity`, {
    method: 'DELETE',
    body: params,
  });
}

// 获取商品列表
export async function getCommodity(params) {
  return request(`${API}/api/commoditys`, {
    method: 'GET',
    body: params,
  });
}

// 查询商品详情
export async function searchCommodity(params) {
  return request(`${API}/api/commoditys`, {
    method: 'GET',
    body: params,
  });
}

// 用户查询所属商品
export async function searchUserCommodity(params) {
  return request(`${API}/api/user/commoditys`, {
    method: 'GET',
    body: params,
  });
}
